import pandas as pd
df = pd.read_csv(r'C:\Users\imane\OneDrive\Desktop\Data4good\p2-arbres-fr.csv', sep =";", encoding = "utf-8")
df.drop('id', axis = 1, inplace= True)
df.drop("complement_addresse",axis =1, inplace = True)
df.drop("numero",axis =1, inplace = True)
df.drop("id_emplacement",axis =1, inplace = True)
df.drop("genre",axis =1, inplace = True)
df.drop("variete",axis =1, inplace = True)
df.drop("remarquable",axis =1, inplace = True)
df.drop("type_emplacement",axis =1, inplace = True)
print("Numéro d'arbres: ",len(df))
Numéro d'arbres: 200137
df.drop(df.index[(df["circonference_cm"] == 0)], axis = 0, inplace=True)
df.drop(df.index[(df["hauteur_m"] == 0)], axis = 0, inplace=True)
df.drop(df.index[(df["circonference_cm"] > 470)], axis = 0, inplace=True)
df.drop(df.index[(df["hauteur_m"] > 35 )], axis = 0, inplace=True)
df.dropna(subset=["circonference_cm"],inplace=True)
df.dropna(subset=["hauteur_m"],inplace=True)
print("Numéro d'arbres: ",len(df))
Numéro d'arbres: 159899
df["hauteur_m"] = 100 * df["hauteur_m"]
new_df = df.rename(columns={"hauteur_m":"hauteur_cm"})
new_df
| domanialite | arrondissement | lieu | libelle_francais | espece | circonference_cm | hauteur_cm | stade_developpement | geo_point_2d_a | geo_point_2d_b | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Jardin | PARIS 7E ARRDT | MAIRIE DU 7E 116 RUE DE GRENELLE PARIS 7E | Marronnier | hippocastanum | 20 | 500 | NaN | 48.857620 | 2.320962 |
| 1 | Jardin | PARIS 7E ARRDT | MAIRIE DU 7E 116 RUE DE GRENELLE PARIS 7E | If | baccata | 65 | 800 | A | 48.857656 | 2.321031 |
| 2 | Jardin | PARIS 7E ARRDT | MAIRIE DU 7E 116 RUE DE GRENELLE PARIS 7E | If | baccata | 90 | 1000 | A | 48.857705 | 2.321061 |
| 3 | Jardin | PARIS 7E ARRDT | MAIRIE DU 7E 116 RUE DE GRENELLE PARIS 7E | Erable | negundo | 60 | 800 | A | 48.857722 | 2.321006 |
| 7 | Jardin | PARIS 16E ARRDT | SQUARE ALEXANDRE ET RENE PARODI / 1 PLACE DE L... | Platane | x hispanica | 260 | 1700 | NaN | 48.876722 | 2.280222 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 198874 | Alignement | PARIS 20E ARRDT | RUE DU GENERAL NIESSEL | Chêne | cerris | 20 | 500 | NaN | 48.848074 | 2.409116 |
| 198875 | Alignement | PARIS 20E ARRDT | RUE DU GENERAL NIESSEL | Chêne | cerris | 20 | 500 | NaN | 48.848226 | 2.409147 |
| 198876 | Alignement | PARIS 20E ARRDT | RUE DU GENERAL NIESSEL | Chêne | cerris | 20 | 500 | NaN | 48.848379 | 2.409179 |
| 198877 | Alignement | PARIS 20E ARRDT | RUE DU GENERAL NIESSEL | Chêne | cerris | 20 | 500 | NaN | 48.848533 | 2.409209 |
| 198878 | Alignement | PARIS 20E ARRDT | RUE DU GENERAL NIESSEL | Chêne | cerris | 20 | 500 | NaN | 48.848843 | 2.409275 |
159899 rows × 10 columns
df.dropna(subset=["stade_developpement"], inplace = True)
print("Numéro d'arbres: ",len(df))
Numéro d'arbres: 129996
new_df.boxplot(column=['circonference_cm'])
<AxesSubplot:>
new_df.boxplot(column=['hauteur_cm'])
<AxesSubplot:>
import missingno as msno
msno.bar(new_df)
<AxesSubplot:>
import seaborn as sns
n_tree = [1 for i in range(len(new_df))]
new_df["n_tree"] = n_tree
new_df["arrondissement"].replace({"PARIS 10E ARRDT":"10E ARR","PARIS 11E ARRDT":"11E ARR","PARIS 12E ARRDT":"12E ARR",
"PARIS 13E ARRDT":"13E ARR","PARIS 14E ARRDT":"14E ARR","PARIS 15E ARRDT":"15E ARR",
"PARIS 16E ARRDT":"16E ARR","PARIS 17E ARRDT":"17E ARR","PARIS 18E ARRDT":"18E ARR",
"PARIS 19E ARRDT":"19E ARR","PARIS 1ER ARRDT":"1ER ARR","PARIS 20E ARRDT":"20E ARR",
"PARIS 2E ARRDT":"2E ARR","PARIS 3E ARRDT":"3E ARR","PARIS 4E ARRDT":"4E ARR",
"PARIS 5E ARRDT":"5E ARR","PARIS 6E ARRDT":"6E ARR","PARIS 7E ARRDT":"7E ARR",
"PARIS 8E ARRDT":"8E ARR","PARIS 9E ARRDT":"9E ARR","SEINE-SAINT-DENIS":"S.S.DENIS",
"VAL-DE-MARNE":"V.MARNE","BOIS DE BOULOGNE":"B. BOULOGNE","BOIS DE VINCENNES":"B.VINCENNES",
"HAUTS-DE-SEINE":"H.SEINE"}, inplace = True)
new_df_2 = new_df.groupby("arrondissement").sum()
new_df_2.drop("circonference_cm",axis =1, inplace = True)
new_df_2.drop("hauteur_cm",axis =1, inplace = True)
new_df_2.drop("geo_point_2d_a",axis =1, inplace = True)
new_df_2.drop("geo_point_2d_b",axis =1, inplace = True)
for_sns = pd.melt(new_df_2.reset_index(),id_vars=['arrondissement'],value_vars=new_df_2.columns)
p = sns.barplot(y="arrondissement",x="value", data = for_sns,hue = "variable")
p.set_title(" Nombre d'arbres par arroundissement")
Text(0.5, 1.0, " Nombre d'arbres par arroundissement")
selected_col = new_df[["arrondissement","circonference_cm","hauteur_cm"]]
new_df_3 = selected_col.copy()
ndf_3 = new_df_3.groupby("arrondissement").mean()
for_sns_2 = ndf_3.reset_index()
g = sns.scatterplot(data = for_sns_2,x = "circonference_cm",y = "hauteur_cm",hue = "arrondissement")
g.set_title("hauteur_cm et circonference_cm moyenne par arrondissement")
Text(0.5, 1.0, 'hauteur_cm et circonference_cm moyenne par arrondissement')
selected_col_2 = new_df[["stade_developpement","hauteur_cm","circonference_cm"]]
new_df_4 = selected_col_2.copy()
ndf_4 = new_df_4.groupby("stade_developpement").mean()
for_sns_3 = ndf_4.reset_index()
import matplotlib.pyplot as plt
fig,ax = plt.subplots()
ax = sns.lineplot(data = for_sns_3, x= "stade_developpement",y="circonference_cm")
ax1 = sns.lineplot(data = for_sns_3,x = "stade_developpement", y = "hauteur_cm")
ax.set_title("Hauteur_cm et circonference_cm moyenne par stade de developpement")
Text(0.5, 1.0, 'Hauteur_cm et circonference_cm moyenne par stade de developpement')
selected_col_3 = new_df[["stade_developpement","n_tree","arrondissement"]]
new_df_5 = selected_col_3.copy()
ndf_5 = new_df_5.groupby(["arrondissement","stade_developpement"]).sum().reset_index()
graph = sns.histplot(data = ndf_5,x= "arrondissement", weights= "n_tree", hue = "stade_developpement", multiple="stack")
graph.set_title("Nombre d'arbres par arrondissement et stade de developpement")
Text(0.5, 1.0, "Nombre d'arbres par arrondissement et stade de developpement")
selected_col_4 = new_df[["n_tree","domanialite","arrondissement"]]
new_df_6 = selected_col_4.copy()
ndf_6 = new_df_6.groupby(["domanialite","arrondissement"]).sum().reset_index()
import plotly.express as px
figure = px.treemap(ndf_6,path = ["domanialite","arrondissement"], values="n_tree")
figure.show()
selected_col_5 = new_df[["arrondissement","n_tree","geo_point_2d_a","geo_point_2d_b"]]
new_df_7 = selected_col_5.copy()
ndf_7 = new_df_7.groupby("arrondissement").sum().reset_index()
ndf_7.drop('geo_point_2d_a', axis = 1, inplace= True)
ndf_7.drop('geo_point_2d_b', axis = 1, inplace= True)
new_df_8 = new_df_7.groupby(["arrondissement"]).nth(0).reset_index()
a = new_df_8["geo_point_2d_a"]
b = new_df_8["geo_point_2d_b"]
ndf_7 = ndf_7.join(a)
ndf_7 = ndf_7.join(b)
import folium
map = folium.Map(location=[48.856614, 2.3522219], zoom_start=14,control_scale=True,tiles="Stamen Terrain")
for i in range(0,len(ndf_7)):
folium.Circle(
location = [ndf_7.iloc[i]["geo_point_2d_a"], ndf_7.iloc[i]["geo_point_2d_b"]],
tooltip = (ndf_7.iloc[i]["arrondissement"],ndf_7.iloc[i]["n_tree"]) ,
radius = int(ndf_7.iloc[i]["n_tree"]) / len(ndf_7), fill = True,
).add_to(map)
map